package com.tanhua.app.controller;

import com.tanhua.app.controllerservice.BaiduService;
import com.tanhua.domain.vo.UserHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class BaiduController {

    @Autowired
    BaiduService baiduService;


    @PostMapping(name = "接受发送过来的地理位置",value = "/baidu/location")
    public ResponseEntity location(@RequestBody Map map){
        Double longitude = (Double) (map.get("longitude"));
        Double latitude = (Double) (map.get("latitude"));
        String addrStr = (String) (map.get("addrStr"));
        System.out.println("前端发送过来的地理位置："+map);
        System.out.println("123");

        // 因为是模拟器（地址是乱的） 所以要改成顺义的地址
        longitude=116.635672;
        latitude=40.169419;
        addrStr="黑马程序员(顺义校区)";

        return baiduService.location(longitude,latitude,addrStr);
    }

    @GetMapping(name = "搜附近",value = "/tanhua/search")
    public ResponseEntity search(String gender,Integer distance){

        return baiduService.search(gender,distance);
    }
}
